package com.son.hotel.common;


import com.son.hotel.execption.BusinessException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class globalExceptionHandler {
    @ExceptionHandler(BusinessException.class)
    public Result<BusinessException> exceptionHandler(BusinessException e){
        return Result.error(e.getCode(),e.getDesc());
    }

    @ExceptionHandler(RuntimeException.class)
    public Result<RuntimeException> exceptionHandler(RuntimeException e){
        return Result.error(ErrorCode.SYSTEM_ERROR);
    }
}
